<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>阳光成单系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="./css/x-admin.css" media="all">
</head>

<body>
<div class="x-body">
  <form class="layui-form" onsubmit="return false" id="form_chanPingXiangQing">
    <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>产品名 </label>
      <div class="layui-input-inline">
        <input type="text" id="chanPinName" name="chanPinName" autocomplete="off" class="layui-input">
      </div>
      <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的名字
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>产品地址 </label>
      <div class="layui-input-inline">
        <input type="text" id="chanPinDiZhi" name="chanPinDiZhi" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的生产地址
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>产品售价 </label>
      <div class="layui-input-inline">
        <input type="text" id="chanPinShouJia" name="chanPinShouJia" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的售价
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>产品市场价</label>
      <div class="layui-input-inline">
        <input type="text" id="chanPinShiChangJia" name="chanPinShiChangJia" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的市场价
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>产品品牌</label>
      <div class="layui-input-inline">
        <input type="text" id="chanPinPaiZi" name="chanPinPaiZi" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的品牌
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>是否过期 </label>
      <div class="layui-input-inline">
         <select id="shiFouGuoqi" name="shiFouGuoqi">
        	<option value="否">否</option>
        	<option value="是">是</option>
        </select>
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品是否过期
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>是否限量 </label>
      <div class="layui-input-inline">
       <select id="shiFouXianLiang" name="shiFouXianLiang">
        	<option value="否">否</option>
        	<option value="是">是</option>
        </select>
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品是否限量
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>保质期 </label>
      <div class="layui-input-inline">
        <input type="text" id="baoZhiQi" name="baoZhiQi" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的保质期
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>加工坊 </label>
      <div class="layui-input-inline">
        <input type="text" id=jiaGongFang name="jiaGongFang" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的加工坊
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>口味 </label>
      <div class="layui-input-inline">
        <input type="text" id="kouWei" name="kouWei" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的口味
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>生产商 </label>
      <div class="layui-input-inline">
        <input type="text" id="shenChangShang" name="shenChangShang" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的生产商
     </div>
     </div>
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>重量 </label>
      <div class="layui-input-inline">
        <input type="text" id="zhongLiang" name="zhongLiang" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的重量
     </div>
     </div>
     
       <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>产品分类 </label>
      <div class="layui-input-inline">
       
        <select name="fenleiId" id="select_chanPinFenLei">
			<option value="">请选择分类</option>					
		</select>
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请输入产品的分类
     </div>
     </div>
     
     
     <div class="layui-form-item">
      <label for="L_email" class="layui-form-label"> <span class="x-red">*</span>图片路径 </label>
      <div class="layui-input-inline">
        <input type="text" id="imgs" name="imgs" autocomplete="off" class="layui-input">
      </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>请选择产品的图片
        <button type="button" class="layui-btn" id="btn_chanPinXiangQing">
			  <i class="layui-icon">&#xe67c;</i>选择图片
		</button>
     </div>
     <label for="L_email" class="layui-form-label"></label>
      <div class="layui-form-mid layui-word-aux">
         <img alt="" width="200px" id="img_chanPinXTuPian" src="../">
     </div>
    		
     </div>
     
    
     
     
     
   
     
     
    <div class="layui-form-item">
      <label for="L_repass" class="layui-form-label"> </label>
      <button  class="layui-btn" onclick="addChanPinXiangQing()"> 添加 </button>
    </div> 
     
  </form>
</div>
<script src="./lib/layui/layui.js" charset="utf-8">
        </script> 
<script src="./js/x-layui.js" charset="utf-8">
        </script> 
<script>
	var $=null;
	var form=null;
	var layer=null;
	layui.use(['form','layer','upload'], function(){
	    $ = layui.jquery;
	   form = layui.form;
	  layer = layui.layer;
	  $(function(){
		  selChanPingFenLei();
	  })
	  
	  
	  
	  
	  var upload = layui.upload;
	   
	  //执行实例
	  var uploadInst = upload.render({
	    elem: '#btn_chanPinXiangQing' //绑定元素
	    ,url: '../adminchanpingxiangqing?reqName=upload' //上传接口
	    ,done: function(res){
	      //上传完毕回调
	      if(res.success){
	    	  $("#imgs").val('images/'+res.remark);
	    	  $("#img_chanPinXTuPian").attr('src','../images/'+res.remark);
	    	  layer.msg("添加成功",{
	    		  icon:1,
	    		  time:2000
	    	  })
	    	  
	      }
	      
	      
	    }
	    ,error: function(){
	      //请求异常回调
	       layer.msg("添加失败",{
	    		  icon:2,
	    		  time:2000
	    	  })
	    }
	  });
  	});     
    function addChanPinXiangQing(){
    	var data=$("#form_chanPingXiangQing").serialize();
    	var array = data.split('&');
    	for(var i=0;i<array.length;i++){
    		 var kwarr = array[i].split('=');
    		if(kwarr[i]===null||kwarr[i]===""){
    			layer.alert('存在没有填的选项');
    		     return false;
    		}
    	}
    	
    	$.post("../adminchanpingxiangqing?reqName=addChanPingXiangQing",data,function(res){
    		if(res.success){
    			layer.msg(res.message);
    			var index = parent.layer.getFrameIndex(window.name);
    			parent.layer.close(index);//关闭当前页
    			parent.getChanPingXiangQingWhereByPage();
    		}else{
    			layer.msg(res.message);
    		}
	
    	},"json")
    }          
    function selChanPingFenLei(){
    	$.post("../adminchanpinfenlei?reqName=selChanPinFenLei",{
    	},function(res){
        		for(var i=0;i<res.length;i++){
        			$("#select_chanPinFenLei").append("<option value='"+res[i].chanPinId+"'>"+res[i].leiMing+"</option>");
        			form.render("select");
        			
        		}
        	},"json");
    }        
           
</script>
</body>
</html>